package com.kumi.core.repository;

import com.kumi.core.domain.Site;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.QueryHints;
import org.springframework.data.repository.Repository;

import javax.persistence.QueryHint;
import java.util.List;

/**
 * SiteDao
 * 
 * @author liufang
 * 
 */
public interface SiteDao extends Repository<Site, Integer> {

	public List<Site> findAll(Specification<Site> spec, Sort sort);

	public List<Site> findAll(Specification<Site> spec);

	public List<Site> findAll(Sort sort);

	public Site findOne(Integer id);

	public Site save(Site bean);

	public void delete(Site bean);
	//用于查询注入，避免在配置文件中配置，更加方便
	@QueryHints(@QueryHint(name = org.hibernate.jpa.QueryHints.HINT_CACHEABLE, value = "true"))
	@Query("from Site bean where bean.number = ?1")
	public List<Site> findByNumber(String number);
}